// 引用
import {
    A_CATE_LIST,
    A_CATE_GOOD
} from '../types'
import {
    getData
} from '../../services/getGoodData'

const state = {
    cateList: [],
    cate_cont: {}
}

const actions = {
    // 获取分类信息
    [A_CATE_LIST]: async ({
        commit
    }, payload) => {
        let res = (await getData(payload)).data.data
        commit(A_CATE_LIST, res)
    },
    // 获取分类对应商品信息
    [A_CATE_GOOD]: async ({
        commit
    }, payload) => {
        let res = (await getData(payload)).data.data
        commit(A_CATE_GOOD, res)
    }
}

const mutations = {
    // 修改state
    [A_CATE_LIST]: (state, payload) => {
        state.cateList = payload
    },
    [A_CATE_GOOD]: (state, payload) => {
        state.cate_cont = payload
    }
}

const getters = {

}

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}